package edu.cn.neusoft.dm.showweb.mapper;

import com.alibaba.fastjson.JSON;
import edu.cn.neusoft.dm.showweb.bean.db.UserInfo;
import edu.cn.neusoft.dm.showweb.bean.db.UserInfoExample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * author:纷羽
 * create at 2018/7/12
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class User {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Test
    public void insert() {
        UserInfo userInfo = new UserInfo();
        userInfo.setIdentify(1);
        userInfo.setUserName("16180600214");
        userInfo.setUserPass("16180600214");
        userInfoMapper.insert(userInfo);
    }

    @Test
    public void select() {
        List<UserInfo> userInfoList = userInfoMapper.selectByExample(null);
        System.out.println(JSON.toJSONString(userInfoList));
    }

    @Test
    public void delete() {
        UserInfoExample example = new UserInfoExample();
        example.createCriteria().andUserNameEqualTo("16180600214");
        userInfoMapper.deleteByExample(example);
    }
}
